import { useI18n } from '@/hooks/web/useI18n';

/** 筛选操作枚举 */
export enum FilterOperateEnum {
  /** 并且 */
  And = 1,
  /** 或者 */
  Or = 2,
  /** 等于 */
  Equal = 3,
  /** 不等于 */
  NotEqual = 4,
  /** 小于 */
  Less = 5,
  /** 小于等于 */
  LessOrEqual = 6,
  /** 大于 */
  Greater = 7,
  /** 大于等于 */
  GreaterOrEqual = 8,
  /** 开始于 */
  StartsWith = 9,
  /** 结束于 */
  EndsWith = 10,
  /** 包含 */
  Contains = 11,
  /** 不包含 */
  NotContains = 12,
}

/** 筛选操作实体 */
export class FilterOperateEntity {
  /** 条件间操作 */
  Operate: FilterOperateEnum;
  /** 条件间操作显示描述 */
  Display: string;

  constructor(operate: FilterOperateEnum) {
    const { t } = useI18n();
    this.Operate = operate;
    switch (operate) {
      case FilterOperateEnum.And:
        // this.Display = '并且';
        this.Display = t('enum.filterOperate.and');
        break;
      case FilterOperateEnum.Or:
        // this.Display = '或者';
        this.Display = t('enum.filterOperate.or');
        break;
      case FilterOperateEnum.Equal:
        // this.Display = '等于';
        this.Display = t('enum.filterOperate.equal');
        break;
      case FilterOperateEnum.NotEqual:
        // this.Display = '不等于';
        this.Display = t('enum.filterOperate.notEqual');
        break;
      case FilterOperateEnum.Less:
        // this.Display = '小于';
        this.Display = t('enum.filterOperate.less');
        break;
      case FilterOperateEnum.LessOrEqual:
        // this.Display = '小于等于';
        this.Display = t('enum.filterOperate.lessOrEqual');
        break;
      case FilterOperateEnum.Greater:
        // this.Display = '大于';
        this.Display = t('enum.filterOperate.greater');
        break;
      case FilterOperateEnum.GreaterOrEqual:
        // this.Display = '大于等于';
        this.Display = t('enum.filterOperate.greaterOrEqual');
        break;
      case FilterOperateEnum.StartsWith:
        // this.Display = '开始于';
        this.Display = t('enum.filterOperate.startsWith');
        break;
      case FilterOperateEnum.EndsWith:
        // this.Display = '结束于';
        this.Display = t('enum.filterOperate.endsWith');
        break;
      case FilterOperateEnum.Contains:
        // this.Display = '包含';
        this.Display = t('enum.filterOperate.contains');
        break;
      case FilterOperateEnum.NotContains:
        // this.Display = '不包含';
        this.Display = t('enum.filterOperate.notContains');
        break;
      default:
        // this.Display = '未知操作';
        this.Display = t('enum.filterOperate.unknown');
        break;
    }
    this.Display = `${operate as number}.${this.Display}`;
  }
}
